/*
 * ﻿Copyright (C) 2013-2014 NewMain Softech
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package com.newmainsoftech.eatestutil.container.glassfish;

import java.io.File;
import java.util.logging.Level;

import com.newmainsoftech.eatestutil.container.AbstractEjbContainerMateImpl;
import com.newmainsoftech.eatestutil.container.ContainerConfig;
import com.newmainsoftech.eatestutil.container.glassfish.GlassfishDaoLoggerConfigurator.GlassfishDaoLoggerEnum;

/**
 * Extension of <code>{@link AbstractEjbContainerMateImpl}</code> for Glassfish.
 * 
 * @author Arata Y.
 */
public abstract class AbstractGlassfishEjbContainerMate extends AbstractEjbContainerMateImpl {
	private EmbeddedGlassfishConfig containerConfig = new EmbeddedGlassfishConfig();
		@Override
		public ContainerConfig getContainerConfig() {
			return containerConfig;
		}
		public EmbeddedGlassfishConfig getEmbeddedGlassfishConfig() {
			return containerConfig;
		}
		
	/**
	 * Get <code>File</code> object for domain.xml Glassfish configuration file.<br />
	 * 
	 * @return <code>File</code> object for domain.xml Glassfish configuration file.
	 */
	public abstract File getDomainXmlFile();
	
	private GlassfishDaoLoggerConfigurator glassfishDaoLoggerConfigurator
	= new GlassfishDaoLoggerConfigurator();
		public GlassfishDaoLoggerConfigurator getGlassfishDaoLoggerConfigurator() {
			return glassfishDaoLoggerConfigurator;
		}
		public void setGlassfishDaoLoggerConfigurator(
				final GlassfishDaoLoggerConfigurator glassfishDaoLoggerConfigurator) {
			this.glassfishDaoLoggerConfigurator = glassfishDaoLoggerConfigurator;
		}
		public void configureGlassfishDaoLoggers( final Level level) {
			final GlassfishDaoLoggerConfigurator glassfishDaoLoggerConfigurator 
			= getGlassfishDaoLoggerConfigurator();
			
			for( GlassfishDaoLoggerEnum glassfishDaoLoggerEnum : GlassfishDaoLoggerEnum.values()) {
				glassfishDaoLoggerEnum.setLevel( level);
				glassfishDaoLoggerConfigurator.setLoggersLevel( glassfishDaoLoggerEnum);
			}
		}
}
